<?php
require_once PATH_SITE.'cn/royan/php/utils/builders/BuilderConfig.builder.php';
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once PATH_SITE.'org/puremvc/php/patterns/proxy/Proxy.php';
/**
 * Description of ConfigProxy
 *
 * @author Royan
 */
class ConfigProxy extends Proxy
{
    const NAME = "ConfigProxy";
    //put your code here
    public function __construct() {
        parent::__construct( ConfigProxy::NAME );
    }
    
    public function load( $value )
    {
        IF ( !file_exists( $value ) )
        {
            Logger::trace( "file '$value' does not exist" );
            throw new Exception( "file '".$value."' does not exist" );
        }
        IF( is_string( $value ) )
        {
            $config = file_get_contents($value);
            IF( !$config )
                Logger::trace( "No Load" );
            
            $builderConfig = new BuilderConfig( json_decode( $config ) );
            
            $this->setData( $builderConfig->build()->getResult() );
            $this->sendNotification(ApplicationMediator::CONFIG_LOAD_COMPLETE );
        }
    }
}

?>
